package com.panopset;

import java.awt.Component;

import javax.swing.JFrame;

import com.panopset.gui.LookAndFeel.Dimensions;

/**
 * GUI Utilities.
 *
 * @author Karl Dinwiddie
 */
public final class UtilGUI {

    /**
     * @return Standard centered frame.
     */
    public static JFrame createStandardFrame() {
        JFrame f = new JFrame();
        f.setSize(Dimensions.WINDOW.getValue());
        f.setLocation(
            com.panopset.Util.centerInScreen(Dimensions.WINDOW.getValue()));
        if (AbstractApplication.getApp() != null) {
            f.setIconImage(AbstractApplication.getApp().getFlexFrame()
                    .getFrame().getIconImage());
        }
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        return f;
    }

    /**
     * Update a component. Calls invalidate on the component, then invalidate
     * on its parent, if the parent exists.
     *
     * @param comp Component.
     */
    public static void updateComponent(final Component comp) {
        comp.invalidate();
        Component p = comp.getParent();
        if (p != null) {
            p.validate();
        }
    }
    /**
     * Prevent instantiation.
     */
    private UtilGUI() { }
}
